package com.tomatozq163.sharding.encryptor;

import com.tomatozq163.sharding.utils.AESUtil;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import java.util.Properties;

public class CustomAESEncryptor implements EncryptAlgorithm {
    private String key;

    @Override
    public String getType() {
        return "customAES";
    }

    @Override
    public Properties getProps() {
        return null;
    }

    @Override
    public void setProps(Properties properties) {
        key = properties.getProperty("aes-key-value");
    }

    @Override
    public void init() {

    }

    @Override
    public String encrypt(Object plainText) {
        return AESUtil.encrypt(plainText.toString(),key);
    }

    @Override
    public Object decrypt(String encStr) {
        return AESUtil.decrypt(encStr, key);
    }
}
